package pratap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;

public class AddContactAction extends Action{

public ActionForward execute(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response)
		throws Exception {
	
	String result="AddContactSucess";
	
  DynaValidatorForm dvf=(DynaValidatorForm)form;
  
  String fn=dvf.get("fname").toString();
  String ln=dvf.get("lname").toString();
  String em=dvf.get("email").toString();
  String ph=dvf.get("phone").toString();
  
  System.out.println(fn);
  System.out.println(ln);
  System.out.println(em);
  System.out.println(ph);
  
  ContactTO cto=new ContactTO();
  cto.setEmail(em);
  cto.setFname(fn);
  cto.setLname(ln);
  cto.setPhone(ph);
  
	request.setAttribute("CTO", cto);
	return mapping.findForward(result);
}
}
